import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'Home',
    component: () => import('../views/Home.vue'),
    meta: {
      title: '房价分析系统 - 首页'
    }
  },
  {
    path: '/analysis',
    name: 'Analysis',
    component: () => import('../views/Analysis.vue'),
    meta: {
      title: '房源分析'
    }
  },
  {
    path: '/data-analysis',
    name: 'DataAnalysis',
    component: () => import('../views/DataAnalysisView.vue'),
    meta: {
      title: '房价数据分析'
    }
  },
  {
    path: '/detail/:id',
    name: 'Detail',
    component: () => import('../views/Detail.vue'),
    meta: {
      title: '房源详情'
    }
  },
  {
    path: '/city-comparison',
    name: 'CityComparison',
    component: () => import('../views/CityComparison.vue'),
    meta: {
      title: '城市房价对比'
    }
  },
  {
    path: '/district-analysis',
    name: 'DistrictAnalysis',
    component: () => import('../views/DistrictAnalysis.vue'),
    meta: {
      title: '区域房价分析'
    }
  },
  {
    path: '/search',
    name: 'Search',
    component: () => import('../views/Search.vue'),
    meta: {
      title: '房源搜索'
    }
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '房价分析系统'
  next()
})

export default router 